<!DOCTYPE html>
<html lang="zh-cn">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">




<title>npm | Miles`s</title>

<link rel="stylesheet" href="https://mada.gitee.io/notes//css/styles.css">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" 
integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/zenburn.min.css" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" integrity="sha256-/BfiIkHlHoVihZdc6TFuj7MmJ0TWcWsMXkeDFwhi0zw=" crossorigin="anonymous"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="https://mada.gitee.io/notes//js/highlight.js"></script>






<div class="container">
    <nav class="navbar level">
      <div class="navbar-brand">
          <a class="nav-item" href="https://mada.gitee.io/notes/"><h1 class="title is-3">Miles`s</h1></a>
      </div>           
      <div class="navbar-menu has-text-centered is-active">
          <div class="navbar-end is-centered">
              
           </div>
      </div>
    </nav>
  </div>
<div class="container">
  <h2 class="subtitle is-6">June 21, 2016</h2>
  <h1 class="subtitle is-size-4-mobile is-size-3-desktop">npm</h1>
  <div class="content">
    

<h3 id="npm">npm</h3>

<h4 id="install">install</h4>

<p><code>npm install npm@latest -g</code></p>

<h4 id="npm-init">npm init</h4>

<p><code>npm init -y</code></p>

<p>跳过提问阶段</p>

<h4 id="npm-set">npm set</h4>

<p>设置环境变量</p>

<h4 id="npm-info-packagename">npm info packagename</h4>

<p>列出模块信息</p>

<h4 id="npm-search">npm search</h4>

<p>搜索仓库。</p>

<h4 id="npm-list">npm list</h4>

<h4 id="npm-install">npm install</h4>

<p>安装不同版本</p>

<pre><code>	npm install sax@latest
    npm install sax@0.1.1
    npm install sax@&quot;&gt;=0.1.0 &lt;0.2.2&quot;
</code></pre>

<h4 id="避免系统权限">避免系统权限</h4>

<p>修改主目录下 .npmrc文件</p>

<p><code>prefix = /home/yourUsername/npm</code></p>

<p><code>mkdir ~/npm</code></p>

<p>在<code>.bash_profile</code>
<code>export PATH=~/npm/bin:$PATH</code></p>

<h4 id="npm-run">npm run</h4>

<h5 id="参数">参数</h5>

<p>使用<code>－－</code> 传参数</p>

<p><code>npm run test -- 300</code></p>

<p><code>－s</code>：关闭npm本身的输出，只输出脚本产生的结果。</p>

<h5 id="scripts-脚本命令的最佳实践">scripts 脚本命令的最佳实践</h5>

<p>npm-run-all</p>

<p>dev</p>

<p>&ldquo;dev&rdquo;:&ldquo;npm-run-all dev:*&rdquo;: 用于继发执行所有 dev 的子命令</p>

<pre><code>&quot;predev:sass&quot; : &quot;node-sass --source-map src/css/t.scss ./dist/sss.css&quot;

&quot;dev:autoprefix&quot;: &quot;postcss --use autoprefixer --autoprefixer...&quot;
</code></pre>

<h5 id="serve-脚本命令">serve 脚本命令</h5>

<p>&ldquo;serve&rdquo;: &ldquo;live-server dist/ &ndash;port=9090&rdquo;</p>

<p>展示指定目录下的 index.html 文件
自动刷新功能</p>

<h5 id="prod-命令">prod 命令</h5>

<p>规定进入生产环境时需要的处理</p>

<pre><code>&quot;prod&quot;: &quot;npm-run-all prod:*&quot;,
&quot;prod:sass&quot;: &quot;node-sass --output-style compressed src/sass/base.scss src/css/prod/hoodie.min.css&quot;,
&quot;prod:autoprefix&quot;: &quot;postcss --use autoprefixer --autoprefixer.browsers &quot;&gt; 5%&quot; --output src/css/prod/hoodie.min.css src/css/prod/hoodie.min.css&quot;
</code></pre>

<h5 id="help">help</h5>

<pre><code>&quot;help&quot;: &quot;markdown-chalk --input DEVELOPMENT.md&quot;
</code></pre>

<p>markdown</p>

<h5 id="docs">docs</h5>

<pre><code>&quot;docs&quot;: &quot;kss-node --source src/sass --homepage ../../styleguide.md&quot;
</code></pre>

<p>kss－node 提供源码的注释生成markdown格式的文档</p>

<h5 id="通配符">通配符</h5>

<ul>
<li>＊ 匹配0个或多个字符</li>
<li>？ 匹配1个字符</li>
<li>[&hellip;] 匹配某个范围的字符。如果该范围的第一个字符是<code>！</code>或者是 <code>^</code>, 则匹配不在该范围的字符</li>
<li>!(pattern|pattern|pattern) 匹配任何不符合给定的模式</li>
<li>?(pattern|pattern|pattern) 匹配0个或1个给定的模式</li>
<li>+(pattern|pattern|pattern) 匹配1个或多个给定的模式</li>
<li>*(a|b|c) 匹配0个或多个给定的模式</li>
<li>@(pattern|pat*|pat?erN) 只匹配给定模式之一！！！</li>
<li>** 如果出现路径部分，表示0个或多个子目录</li>
</ul>

  </div>
</div>
<div class="container has-text-centered">
    
</div>

<div class="container has-text-centered">
  
</div>
<section class="section">
  <div class="container has-text-centered">
    <p></p>
  </div>
</section>


